package com.haojg.service;

import com.haojg.model.User;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserAiService implements CustomerMcpService {
    private List<User> users = new ArrayList<>() {{
        add(new User("张三", "男", "20250001"));
        add(new User("李四", "男", "20250002"));
        add(new User("王五", "男", "20250003"));
        add(new User("赵六", "男", "20250004"));
        add(new User("张八", "男", "20250005"));
    }};

    @Tool(description = "根据用户名查询用户信息")
    public List<User> selectByName(@ToolParam(description = "用户名") String username) {
        System.out.println("要查找的用户username：" + username);
        return users.stream().filter(u -> u.getName().contains(username)).toList();
    }


    @Tool(description = "根据工号查询用户信息")
    public List<User> selectByWorkNo(@ToolParam(description = "用户工号") String workNo) {
        System.out.println("要查找的用户workNo：" + workNo);
        return users.stream().filter(u -> u.getWorkNo().contains(workNo)).toList();
    }

}
